﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;

namespace LZ.DCode.Authorization
{
    public class DCodeAuthorizationProvider : AuthorizationProvider
    {


        public override void SetPermissions(IPermissionDefinitionContext context)
        {

            var pages = context.CreatePermission(PermissionNames.Pages, L("Pages"));
            pages.CreateChildPermission(PermissionNames.Pages_Users, L("Users"));
            pages.CreateChildPermission(PermissionNames.Pages_Roles, L("Roles"));
            pages.CreateChildPermission(PermissionNames.Pages_Home, L("Home"));
        var WeChat= pages.CreateChildPermission(PermissionNames.Pages_WeChat, L("WeChat"));
            WeChat.CreateChildPermission(PermissionNames.Pages_WeChat_ReplyMessage, L("WeChat_ReplyMessage"));
            WeChat.CreateChildPermission(PermissionNames.Pages_WeChat_AttentionReply, L("WeChat_AttentionReply"));

        var DingTalk= pages.CreateChildPermission(PermissionNames.Pages_DingTalk, L("DingTalk"));
            DingTalk.CreateChildPermission(PermissionNames.Pages_DingTalk_Organizational, L("DingTalk_Organizational"));
            DingTalk.CreateChildPermission(PermissionNames.Pages_DingTalk_Config, L("DingTalk_Config"));

        var SystemManagement= pages.CreateChildPermission(PermissionNames.Pages_SystemManagement, L("SystemManagement"));
            SystemManagement.CreateChildPermission(PermissionNames.Pages_SystemManagement_OrganizationUnit, L("SystemManagement_OrganizationUnit"));
            SystemManagement.CreateChildPermission(PermissionNames.Pages_SystemManagement_User, L("SystemManagement_User"));
            SystemManagement.CreateChildPermission(PermissionNames.Pages_SystemManagement_Role, L("SystemManagement_Role"));
            SystemManagement.CreateChildPermission(PermissionNames.Pages_SystemManagement_Dictionaries, L("SystemManagement_Dictionaries"));
            SystemManagement.CreateChildPermission(PermissionNames.Pages_SystemManagement_AuditLog, L("SystemManagement_AuditLog"));
            context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);


        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, DCodeConsts.LocalizationSourceName);
        }
    }
}

